/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conexion;

import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Miguel Pichipillan S
 */
public class Consultar {
    
    private Coneccion conexion;
    
    public Consultar (){
        conexion = new Coneccion();
    }
    
    
    
    public ResultSet Consulta (String query) {
         ResultSet rs;
        try {
           
            conexion.crearConeccion();
            conexion.getEstamento().executeQuery(query); 
            rs =  conexion.getEstamento().getResultSet();
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Error en la ejecución del query\n" + ex.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
            rs = null;
        }
         return rs;
    }
    
    public void cerrarConeccion () {
        conexion.cerrarConeccion();
    }
   
    
}
